//
//  YDMyMemberCell.m
//  PeiZiWangBei
//
//  Created by 巨彦新 on 2017/11/21.
//  Copyright © 2017年 LK-IOS. All rights reserved.
//

#import "YDMyMemberCell.h"
#import "YDTuiGuangMemberModel.h"

@interface YDMyMemberCell()
@property (nonatomic , weak) UIView *lineView;
@property (nonatomic, strong)UILabel *phoneLbl;

@property (nonatomic, strong)UILabel *priceLbl;

@property (nonatomic, strong)UILabel *dateLbl;
@end

@implementation YDMyMemberCell

-(void)setModel:(YDTuiGuangMemberModel *)model
{
    _model = model;
    if (model.index == 0) {
        self.phoneLbl.textColor = [UIColor colorWithHexString:blueyGrey];
        self.phoneLbl.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        self.phoneLbl.textAlignment = NSTextAlignmentCenter;
        
        self.dateLbl.textColor = [UIColor colorWithHexString:blueyGrey];
        self.dateLbl.font = [UIFont systemFontOfSize:font12ScreenWRate * LKScreenW];
        self.dateLbl.textAlignment = NSTextAlignmentCenter;
        
        self.phoneLbl.text = model.phoneNumber;
        self.dateLbl.text = model.money;
        
    }else{
        
        
        self.phoneLbl.textColor = [UIColor colorWithHexString:dark];
        self.phoneLbl.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        self.phoneLbl.textAlignment = NSTextAlignmentLeft;
        self.dateLbl.textColor = [UIColor colorWithHexString:dark];
        self.dateLbl.font = [UIFont systemFontOfSize:font14ScreenWRate * LKScreenW];
        self.dateLbl.textAlignment = NSTextAlignmentRight;
        
        self.phoneLbl.text = model.phone;
        self.dateLbl.text = model.pzCreateTime;
        
    }
    

}

+ (instancetype)cellWithTableview:(UITableView *)tableView
{
    static NSString *myMemberCell = @"YDMyMemberCell";
    YDMyMemberCell *cell = [tableView dequeueReusableCellWithIdentifier:myMemberCell];
    if (cell == nil) {
        cell = [[YDMyMemberCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myMemberCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor whiteColor];
        self.contentView.backgroundColor = [UIColor whiteColor];
        [self lineView];
        [self phoneLbl];
//        [self priceLbl];
        [self dateLbl];
        
    }
    return self;
}
-(UIView *)lineView
{
    if (_lineView == nil) {
        UIView *lineView = [[UIView alloc] init];
        [self.contentView addSubview:lineView];
        lineView.backgroundColor = NumberColor(247, 247, 247);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(self);
            make.height.equalTo(@1);
        }];
        _lineView = lineView;
    }
    return _lineView;
}
-(UILabel *)phoneLbl
{
    if (_phoneLbl == nil) {
        UILabel *phoneLbl = [[UILabel alloc] init];
        [self.contentView addSubview:phoneLbl];
        phoneLbl.backgroundColor = [UIColor clearColor];
        [phoneLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self).offset(rate375(20));
            make.width.equalTo(@(rate375(83)));
            make.centerY.equalTo(self);
        }];
        phoneLbl.adjustsFontSizeToFitWidth = YES;
        _phoneLbl = phoneLbl;
    }
    return _phoneLbl;
}
-(UILabel *)priceLbl
{
    if (_priceLbl == nil) {
        UILabel *priceLbl = [[UILabel alloc] init];
        [self.contentView addSubview:priceLbl];
        priceLbl.backgroundColor = [UIColor clearColor];
        priceLbl.textAlignment = NSTextAlignmentCenter;
        [priceLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self);
        }];
        priceLbl.adjustsFontSizeToFitWidth = YES;
        _priceLbl = priceLbl;
    }
    return _priceLbl;
}
-(UILabel *)dateLbl
{
    if (_dateLbl == nil) {
        UILabel *dateLbl = [[UILabel alloc] init];
        [self.contentView addSubview:dateLbl];
        dateLbl.backgroundColor = [UIColor clearColor];
        [dateLbl mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self).offset(-rate375(20));
            make.width.equalTo(@(rate375(70)));
            make.centerY.equalTo(self);
        }];
        dateLbl.adjustsFontSizeToFitWidth = YES;
        _dateLbl = dateLbl;
    }
    return _dateLbl;
}

@end
